package com.prs.crm.action.oa;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.ui.PaginationSupport;

import com.prs.crm.action.FlowAction;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.oa.Knowledge;
import com.prs.crm.service.oa.KnowledgeService;

public class KnowledgeFlowAction extends FlowAction<Knowledge>{

	private static final long serialVersionUID = 1L;
	
	private KnowledgeService knowledgeService;
	
	private Knowledge knowledge;

	
	private PaginationSupport pagination;

	public void setKnowledgeService(KnowledgeService knowledgeService) {
		this.knowledgeService = knowledgeService;
	}

	public KnowledgeService getKnowledgeService() {
		return knowledgeService;
	}
	
	public void setKnowledge(Knowledge knowledge) {
		this.knowledge = knowledge;
	}

	public Knowledge getKnowledge() {
		return knowledge;
	}


	
	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	@Action("listKnowledgeFlow")
	public String execute()
	{
		pagination = this.getPaginationHelper().prepare(pagination);
		pagination= this.getKnowledgeService().listFlowTask(Knowledge.class,pagination, 
				AppContext.getAccountContext().currentUser());
		return SUCCESS;
	}
	
	@Action("editKnowledgeFlowTask")
	public String edit()
	{
		displayEndNodes();
		return SUCCESS;
	}

	@Action(value="submitKnowledgeFlowTask",results={@Result(name="success",type="redirect",location="listKnowledgeFlow")})
	public String submitTask()
	{
		this.getKnowledgeService().execute(getNode(), getDetail(), knowledge
				,AppContext.getAccountContext().currentUser());
		return SUCCESS;
	}
	

	
}
